Skip to content

Conversation

senthilengg
Copy link

@senthilengg senthilengg commented Oct 4, 2025

Description (*)

  1. Moving $this->getEntity()->getEntityIdField(); lookup outside of the foreach
  2. Processing the result of select query and preparing [product_id => [attribute_code => value, attribute_code1 => value1]]
  3. Calling _setItemAttributeValue only once per $selectGroups instead of per $selectGroups, per attribute and per product
  4. Return same response as the original function

Fixed Issues (if relevant)

  1. Fixes magento/magento2 Time complexity of _loadAttributes in Eav\Model\Entity\Collection\AbstractCollection increases with number of products in cart and attributes #40216

Manual testing scenarios (*)

  1. Check all areas thats hitting the EAV

Result

Without this PR - Too many calls to _setItemAttributeValue function
image

With PR - Only one call to _setItemAttributeValue function
image

Additional Questions

Since array_replace is memory intensive for large array would it benefit over all or not ?

Copy link

m2-assistant bot commented Oct 4, 2025

Hi @senthilengg. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

Copy link

Failed to run the builds. Please try to re-run them later.

@senthilengg
Copy link
Author

@magento run unit Tests

@senthilengg
Copy link
Author

@magento run Database Compare,Functional Tests CE,Functional Tests EE,Functional Tests B2B,Integration Tests,Magento Health Index,Sample Data Tests CE,Sample Data Tests EE,Sample Data Tests B2B,Static Tests,WebAPI Tests,Semantic Version Checker

@senthilengg senthilengg changed the title #40216-Replacing nested foreach with array_replace to reduce time complexity #40216-Replacing nested foreach with array_union to reduce time complexity Oct 4, 2025
@senthilengg
Copy link
Author

@magento run Functional Tests CE,Static Tests,WebAPI Tests

@senthilengg senthilengg changed the title #40216-Replacing nested foreach with array_union to reduce time complexity #40216-Replacing nested foreach with array union (+) to reduce time complexity Oct 4, 2025
@senthilengg
Copy link
Author

@magento run Functional Tests EE,Functional Tests B2B,Integration Tests

@senthilengg
Copy link
Author

@magento run Functional Tests CE

@senthilengg
Copy link
Author

@magento run WebAPI Tests

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Oct 7, 2025
@github-project-automation github-project-automation bot moved this to Pending Review in Pull Requests Dashboard Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review
Projects
Status: Pending Review
Development

Successfully merging this pull request may close these issues.

2 participants